// FormatUtils.cpp

#include "StdAfx.h"

#include "FormatUtils.h"
#include "ResourceString.h"

#ifdef LANG
#include "Common/Lang/LangUtils.h"
#endif

namespace Common
{
namespace String
{

CString NumberToString(UINT64 number)
{
  TCHAR numberString[32];
  _ui64tot(number, numberString, 10);
  return numberString;
}

CString PatternFormat(const CString &format, const CString &argument, LPCTSTR pattern)
{
	CString result = format;
	if(NULL == pattern || _T('\0') == *pattern)
		return result;
	
	result.Replace(pattern, argument);
	return result;
}

CString PatternFormat(UINT resourceID,
    #ifdef LANG
    UINT32 langID,
    #endif
    const CString &argument, LPCTSTR pattern)
{
  return PatternFormat(
    #ifdef LANG
    Lang::LangString(resourceID, langID),
    #else
    NWindows::MyLoadString(resourceID),
    #endif
    argument);
}

}
}